package weifei.live.simulation.filter;

import jakarta.servlet.*;

import java.io.IOException;


// @WebFilter
public class CharsetEncodingFilter implements Filter
{

    @Override
    public void init(FilterConfig filterConfig)
            throws ServletException
    {
        Filter.super.init(filterConfig);
        System.out.println("CharsetEncodingFilter init");
    }


    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
            throws IOException, ServletException
    {
        System.out.println("CharsetEncodingFilter doFilter");
        servletRequest.setCharacterEncoding("UTF-8");
        servletResponse.setCharacterEncoding("UTF-8");
        filterChain.doFilter(servletRequest, servletResponse);
    }
}

